package com.jz.pay.factories;

import com.jz.pay.factories.dto.WrapperDTO;
import com.jz.pay.factories.tmp.OnethingProcess;

import java.util.ArrayList;
import java.util.List;

public class FactoryManager {

    private final List<OnethingFactory> factorys = new ArrayList<>();
    private final List<OnethingProcess> processs = new ArrayList<>();
    public void add(OnethingFactory onethingFactory){
        factorys.add(onethingFactory);
    }
    public void addProcess(OnethingProcess onethingProcess){
        processs.add(onethingProcess);
    }

    public OnethingFactory getFactory(String str){
        for (OnethingFactory onethingFactory : factorys) {
            if (onethingFactory.isCurrent(str)){
                return onethingFactory;
            }
        }
        return null;
    }
    public OnethingProcess getOnethingProcess(WrapperDTO dto){
        for (OnethingProcess onethingProcess : processs) {
            if (onethingProcess.isCurrent(dto)){
                return onethingProcess;
            }
        }
        return null;
    }
}
